const Koa = require('koa');
const app = new Koa();

app.use(async (ctx, next) => {
    await next();
    const rt = ctx.response.get('123');
    console.log(`${ctx.method} ${ctx.url} - ${rt}`);
})

app.use(async (ctx, next) => {
    const start = Date.now();
    await next();
    const ms = Date.now() - start;
    console.log(`${ms}ms`)
})

app.use(async (ctx, next) => {
    ctx.body = 'hello world'
    console.log(ctx.body)
    await next();
})

app.use(async (ctx, next) => {
    console.log('自定义中间件')
})

app.listen('8888', ()=>{
    console.log('http://localhost:8888')
})